$(function () {
    var loginStatus;
    $.post("../user/login_status", function (data) {
        loginStatus = data;
    });

    /*$(".js-download").click(function () {
        /!*if ("yes" == loginStatus) {
            // 下载

        } else {
            alert("请登录");
        }*!/
        var temp = [
            {"mid" : 1},
            {"mid" : 3},
            {"mid" : 4}
        ];
        $.post(  "../download.action",
                 {"data":JSON.stringify(temp)},
                  function (data) {
            var abc = document.createElement("a");
            abc.setAttribute("href", data[1].url);
            abc.setAttribute("download", "1.mp3");
            abc.click();
        }, "JSON")

    })*/



    var objWin = null;
    $(".js-play").click(function () {
        var $type = $(this).attr("data-type");
        var $id = $(this).attr("data-id");
        //判断播放器页面是否打开
        if (objWin == null || objWin.closed) {
            objWin = window.open("http://localhost:8080/other/mid.html", "tag");
        } else {
            alert("已加入播放器！");
        }
        $.post("http://localhost:8080/music/addto_player", "id="+$id+"&type="+$type+"&play=1");
    })
})